﻿
using SIG.Model.Store;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace SIG.Model.Mapping
{ 
    public class GoodsPhotoMap : EntityTypeConfiguration<GoodsPhoto>
    {
        public GoodsPhotoMap()
        {
            this.HasKey(c => c.Id);

            this.Property(p => p.Id)
                .HasColumnName("Id")
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.ToTable("GoodsPhotoSet");

        
            this.Property(p => p.Thumbnail).HasMaxLength(150);
            this.Property(p => p.GoodsId).IsRequired();
            this.Property(p => p.ImageURL).HasMaxLength(150);           

            this.HasRequired(p => p.Goods).WithMany(h => h.GoodsPhotos).HasForeignKey(p => p.GoodsId)
                 .WillCascadeOnDelete(true);
        }
    }
}
